1
|
|
|
import { BaseEndpoint, QueryParameters } from './baseEndpoint'; |
2
|
|
|
import { |
3
|
|
|
SearchCompaniesResponse, |
4
|
|
|
SearchCollectionsResponse, |
5
|
|
|
SearchKeywordsResponse, |
6
|
|
|
SearchMovieResponse, |
7
|
|
|
SearchPeopleResponse, |
8
|
|
|
SearchTVResponse, |
9
|
|
|
SearchMultiResponse, |
10
|
|
|
MovieSearchQuery, |
11
|
|
|
MultiSearchQuery, PeopleSearchQuery, TVSearchQuery, |
12
|
|
|
} from '../interfaces/search'; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Search Endpoint Class |
16
|
|
|
*/ |
17
|
|
|
export class Search extends BaseEndpoint { |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Search for companies. |
21
|
|
|
* @param { string } query |
22
|
|
|
* @return { Promise<SearchCompaniesResponse> } |
23
|
|
|
* @see https://developers.themoviedb.org/3/search/search-companies |
24
|
|
|
*/ |
25
|
|
|
public async company(query: string): Promise<SearchCompaniesResponse> { |
26
|
|
|
return this.sendGetRequest('search/company', { query } as QueryParameters); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Search for collections. |
31
|
|
|
* @param { string } query |
32
|
|
|
* @return { Promise<SearchCollectionsResponse> } |
33
|
|
|
* @see https://developers.themoviedb.org/3/search/search-collections |
34
|
|
|
*/ |
35
|
|
|
public async collection(query: string): Promise<SearchCollectionsResponse> { |
36
|
|
|
return this.sendGetRequest('search/collection', { query } as QueryParameters); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Search for keywords. |
41
|
|
|
* @param { string } query |
42
|
|
|
* @return { Promise<SearchKeywordsResponse> } |
43
|
|
|
* @see https://developers.themoviedb.org/3/search/search-keywords |
44
|
|
|
*/ |
45
|
|
|
public async keyword(query: string): Promise<SearchKeywordsResponse> { |
46
|
|
|
return this.sendGetRequest('search/keyword', { query } as QueryParameters); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Search for movies. |
51
|
|
|
* @param { string } query |
52
|
|
|
* @param { MovieSearchQuery } parameters |
53
|
|
|
* @return { Promise<SearchMovieResponse> } |
54
|
|
|
* @see https://developers.themoviedb.org/3/search/search-movies |
55
|
|
|
*/ |
56
|
|
|
public async movie(query: string, parameters: MovieSearchQuery = {}): Promise<SearchMovieResponse> { |
57
|
|
|
return this.sendGetRequest('search/movie', { ...{ query }, ...parameters } as QueryParameters); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Search multiple models in a single request. |
62
|
|
|
* Multi search currently supports searching for movies, tv shows and people in a single request. |
63
|
|
|
* @param { string } query |
64
|
|
|
* @param { MultiSearchQuery } parameters |
65
|
|
|
* @return { Promise<SearchMultiResponse> } |
66
|
|
|
* @see https://developers.themoviedb.org/3/search/multi-search |
67
|
|
|
*/ |
68
|
|
|
public async multi(query: string, parameters: MultiSearchQuery = {}): Promise<SearchMultiResponse> { |
69
|
|
|
return this.sendGetRequest('search/multi', { ...{ query }, ...parameters } as QueryParameters); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Search for people. |
74
|
|
|
* @param { string } query |
75
|
|
|
* @param { PeopleSearchQuery } parameters |
76
|
|
|
* @return { Promise<SearchPeopleResponse> } |
77
|
|
|
* @see https://developers.themoviedb.org/3/search/search-people |
78
|
|
|
*/ |
79
|
|
|
public async people(query: string, parameters: PeopleSearchQuery = {}): Promise<SearchPeopleResponse> { |
80
|
|
|
return this.sendGetRequest('search/people', { ...{ query }, ...parameters } as QueryParameters); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Search for a TV show. |
85
|
|
|
* @param { string } query |
86
|
|
|
* @param { PeopleSearchQuery } parameters |
87
|
|
|
* @return { Promise<SearchTVResponse> } |
88
|
|
|
* @see https://developers.themoviedb.org/3/search/search-tv-shows |
89
|
|
|
*/ |
90
|
|
|
public async tv(query: string, parameters: TVSearchQuery = {}): Promise<SearchTVResponse> { |
91
|
|
|
return this.sendGetRequest('search/tv', { ...{ query }, ...parameters } as QueryParameters); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
} |
95
|
|
|
|